﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Concurrent;
using System.ComponentModel.DataAnnotations.Schema;

namespace Chat
{
    [Serializable]
    public class ChatUser
    {
        /// <summary>
        /// 暂时放这里，假装是程序启动时，自动映射
        /// </summary>
        static ChatUser()
        {
            MessagePack.Resolvers.StandardResolver.Instance = new MyResolver();
        }
        public ChatUser()
        {
        }

        public ChatUser(string id,string name)
        {
            Id = id;
            Name = name;
        }

        public string Id { get;  }

        public string Name { get; set; }

        [NotMapped]
        [NonSerialized]
        public string RuMing = null;

        public override string ToString()
        {
            return $"[{Name}:{Id},{RuMing}]";
        }

        public static readonly ConcurrentBag<ChatUser> OnlineUsers = new ConcurrentBag<ChatUser>();
    }
}
